﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Slick.MapEditor;
using Clandestine.Entities;
using System.Threading;
using Clandestine;

namespace Slick
{
    public partial class EntityPaletteControl : UserControl
    {
        public Map Map;

        public EntityPaletteControl()
        {
            InitializeComponent();

            // Add list of available entities to pallete
            foreach (EntityType et in Slick.MapEditor.EntityManager.ListOfAvailableEntities)
            {
                listEntities.Items.Add(et);
            }
        }

        public void Initialise(Map map)
        {
            // Setup stuff
            this.Map = map;
        }

        /// <summary>
        /// Called when user changes selection in entity palette. This is the palette of entities we can add to the map,
        /// NOT existing instances.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void listEntities_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Change selected entity in pallete.
            lock (Map.Entities.SelectedEntityTypeBlob)
                Map.Entities.SelectedEntityType = (EntityType)listEntities.SelectedItems[0];
        }
    }
}
